/*
 * @describe 用户信息 Service
 * @author yisin
 * @date 2015-03-29 20:21:55
 */
package com.yisin.pbox.www.userInfo.service;

import org.springframework.stereotype.Service;

import com.yisin.pbox.bean.pojo.system.UserInfo;
import com.yisin.pbox.frame.common.Response;
import com.yisin.pbox.frame.common.SpringContainer;
import com.yisin.pbox.frame.common.StatusCode;
import com.yisin.pbox.frame.log.ILogger;
import com.yisin.pbox.frame.log.LogFactory;
import com.yisin.pbox.www.userInfo.IUserInfoDao;
import com.yisin.pbox.www.userInfo.IUserInfoService;

/**
 * <pre>
 * 用户信息 Service
 * </pre>
 * 
 * @author yisin
 * @date 2015-03-29 20:21:55
 * 
 */
@Service("userInfoService")
public class UserInfoService implements IUserInfoService {
	private static ILogger logger = LogFactory
			.getDefaultLogger(UserInfoService.class);

	/**
	 * <pre>
	 * 根据ID获取用户信息数据
	 * </pre>
	 * 
	 * @author yisin	 
	 */
	public Response getDataById(int id) {
		logger.debug("In getDataById");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.getDataById(id);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 模糊搜索用户信息数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response loadAndSearch(UserInfo userInfo) {
		logger.debug("In loadAndSearch");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.loadAndSearch(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 高级搜索用户信息数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response advancedSearch(UserInfo userInfo) {
		logger.debug("In advancedSearch");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.advancedSearch(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}
	
	/**
	 * <pre>
	 * 精确查询用户信息数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response selectDataForAccurate(UserInfo userInfo) {
		logger.debug("In selectDataForAccurate");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.selectDataForAccurate(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 新增用户信息记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response insertData(UserInfo userInfo) {
		logger.debug("In insertData");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.insertData(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 修改用户信息记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response updateData(UserInfo userInfo) {
		logger.debug("In updateData");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.updateData(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 删除用户信息记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response deleteData(UserInfo userInfo) {
		logger.debug("In deleteData");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.deleteData(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}
	
	/**
	 * <pre>
	 * 审核用户信息记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2015-03-29 20:21:55
	 */
	public Response auditingData(UserInfo userInfo) {
		logger.debug("In auditingData");
		Response res = new Response();
		try {
			IUserInfoDao rdao = (IUserInfoDao) SpringContainer.getBeanByName("userInfoDao");
			res = rdao.auditingData(userInfo);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

}
